package edu.zut.cs.software.perfect.student.service;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import edu.zut.cs.software.perfect.base.service.GenericGenerator;
import edu.zut.cs.software.perfect.student.domain.Classes;
import edu.zut.cs.software.perfect.student.domain.Student;

/**
 * @ClassName ClassEntityGenerator
 * @Description TODO
 * @Author jihao
 * @Date 2020年6月3日 下午18:43:49
 * @Version 1.0
 */
public class ClassesEntityGenerator extends GenericGenerator{

		ClassesManager classesManager;
		StudentManager studentManager;
		
		@Autowired
		public void setClassesManager(ClassesManager classesManager) {
			this.classesManager = classesManager;
		}

		@Autowired
		public void setStudentManager(StudentManager studentManager) {
			this.studentManager = studentManager;
		}
		
		@Test
		public void testALL() {
			int num_class = 4;
			int num_student = 4;
			for (int i = 0; i < num_class; i++) {
				Classes classes = new Classes(); 
				classes.setClassID(String.valueOf(161+10*i));
				classes = this.classesManager.save(classes);
				for (int j = 0; j < num_class; j++) {
					Classes c = new Classes(); 
					c.setClassID(String.valueOf(161+10*i));
					c.setParent(classes); 
					c = this.classesManager.save(c);
					for (int k = 0; k < num_student; k++) {
						Student stu = new Student();
						stu.setName("name_" + i + "_" + j + "_" + k);
						stu.setClasses(c); 
						stu = this.studentManager.save(stu);
						assertNotNull(stu);
					}
				}
			}
		}
}
